from django.db import models


# Create your models here.
class Host(models.Model):
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')

    host = models.GenericIPAddressField(verbose_name='主机地址')
    port = models.IntegerField(default=3306, verbose_name='主机端口')

    authtype = models.IntegerField(choices=((1, 'password'), (2, 'publickey')), verbose_name='认证类型')

    username = models.CharField(max_length=64, verbose_name='用户名')
    password = models.CharField(max_length=512, null=True, verbose_name='密码')

    notes = models.TextField(null=True, verbose_name='备注')

    def __str__(self):
        return self.host

    class Meta:
        default_permissions = ()

        permissions = (
            ("select", "查看主机列表"),
            ("change", "修改主机信息"),
            ("webssh", "WebSSH连接主机")
        )
